package com.robotserver.orders.config;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author jianghan
 * @date 2019-10-15 13:39
 */
//@Configuration
public class ZkConfig {
    /*@Value("${curator.retryCount}")
    private int retryCount;
    @Value("${curator.elapsedTimeMs}")
    private int elapsedTimeMs;
    @Value("${curator.connect}")
    private String connect;
    @Value("${curator.sessionTimeoutMs}")
    private int sessionTimeoutMs;
    @Value("${curator.connectionTimeoutMs}")
    private int connectionTimeoutMs;
    @Value("${orders.server.node}")
    private String orderServerNode;

    public int getRetryCount() {
        return retryCount;
    }

    public void setRetryCount(int retryCount) {
        this.retryCount = retryCount;
    }

    public int getElapsedTimeMs() {
        return elapsedTimeMs;
    }

    public void setElapsedTimeMs(int elapsedTimeMs) {
        this.elapsedTimeMs = elapsedTimeMs;
    }

    public String getConnect() {
        return connect;
    }

    public void setConnect(String connect) {
        this.connect = connect;
    }

    public int getSessionTimeoutMs() {
        return sessionTimeoutMs;
    }

    public void setSessionTimeoutMs(int sessionTimeoutMs) {
        this.sessionTimeoutMs = sessionTimeoutMs;
    }

    public int getConnectionTimeoutMs() {
        return connectionTimeoutMs;
    }

    public void setConnectionTimeoutMs(int connectionTimeoutMs) {
        this.connectionTimeoutMs = connectionTimeoutMs;
    }

    public String getOrderServerNode() {
        return orderServerNode;
    }

    public void setOrderServerNode(String orderServerNode) {
        this.orderServerNode = orderServerNode;
    }

    @Bean(initMethod = "start")
    public CuratorFramework zkClient(){
        return CuratorFrameworkFactory.builder().connectString(connect).
                        sessionTimeoutMs(sessionTimeoutMs).
                        connectionTimeoutMs(connectionTimeoutMs).
                        retryPolicy(new ExponentialBackoffRetry(elapsedTimeMs,retryCount)).build();
    }*/
}
